# -*- encoding:utf-8 -*-
import sys
sys.path.append("..")

from createdic import pinyin213yun
from yun13 import get13yuncode,YunKeyException

import unittest

class testp2y(unittest.TestCase):
    """
    test the pinyin213yun function
    """
    def testtrue(self):
        dic = {
            "de2":2,
            "hai3":6,
            "xi1":4,}
        for k in dic.keys():
            self.assertEqual(pinyin213yun(k),dic[k])

class testyun13(unittest.TestCase):
    """
    test the yun13
    """
    def testtrue(self):
        dic = {
            u"我":[2],
            u"累":[7],
            u'膧':[12,13]}
        for k in dic.keys():
            self.assertEqual(get13yuncode(k),dic[k])

    def testexcept(self):
        self.assertRaises(YunKeyException,get13yuncode,'D')

if __name__== "__main__":
    unittest.main()
